//
//  MainViewController.m
//  NumberConverter
//
//  Created by Kyle on 10/25/09.
//  Copyright __MyCompanyName__ 2009. All rights reserved.
//

#import "MainViewController.h"
#import "MainView.h"
#include <math.h>
#include <string>
#include <sstream>
#include <iostream>
#include <stack>
#include "Conversion.h"

using namespace std;

@implementation MainViewController

@synthesize rowOfComponent1, rowOfComponent2;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
	{
        // Custom initialization
    }
    return self;
}


NSString *globalString = [[NSString alloc] init]; //independent of convert function global string will have a value

- (IBAction)convert:(id)sender 
{	
    //Variables for every function
	NSString *inputText = [[NSString alloc] init];
	inputText = globalString; //set the inputText string to the global string
	if (input.text != NULL)
	{
		inputText = input.text;
		globalString = input.text;
	}
	
	NSLog(rowOfComponent1); //Print the value of the first component selected to console
	NSLog(rowOfComponent2); //Print the value of the second component selected to console
	
	//Binary to Decimal
	if ([rowOfComponent1 compare:@"Binary"]==0 && [rowOfComponent2 compare:@"Decimal"]==0)
		[self bintoDec:inputText fromFunction:NO];

	//Binary to Hexadecimal
	else if ([rowOfComponent1 compare:@"Binary"]==0 && [rowOfComponent2 compare:@"Hex"]==0)
		[self bintoHex:inputText fromFunction:NO];
	
	//Binary to Octal    -----  Conversion is off ----  Seems to add on instead of new one.
	else if ([rowOfComponent1 compare:@"Binary"]==0 && [rowOfComponent2 compare:@"Octal"]==0)
		[self bintoOct:inputText fromFunction:NO];
		
	//Decimal to Binary  -----  THERE IS AN ERROR IN THIS FUNCTION
	else if ([rowOfComponent1 compare:@"Decimal"]==0 && [rowOfComponent2 compare:@"Binary"]==0)
		[self dectoBin:inputText];
	
	//Decimal to Hexadecimal
	else if ([rowOfComponent1 compare:@"Decimal"]==0 && [rowOfComponent2 compare:@"Hex"]==0)
		[self dectoHex:inputText];
	
	//Decimal to Octal
	else if ([rowOfComponent1 compare:@"Decimal"]==0 && [rowOfComponent2 compare:@"Octal"]==0)
		[self dectoOct:inputText];
	
	//Hexadecimal to Binary
	else if ([rowOfComponent1 compare:@"Hex"]==0 && [rowOfComponent2 compare:@"Binary"]==0)
        [self hextoBin:inputText fromFunction:NO];
	//Hexadecimal to Decimal
	else if ([rowOfComponent1 compare:@"Hex"]==0 && [rowOfComponent2 compare:@"Decimal"]==0)
		[self hextoDec:inputText];
	
	//Hexadecimal to Octal
	else if ([rowOfComponent1 compare:@"Hex"]==0 && [rowOfComponent2 compare:@"Octal"]==0)
		[self hextoOct:inputText];
	
	//Octal to Hexadecimal
	else if ([rowOfComponent1 compare:@"Octal"]==0 && [rowOfComponent2 compare:@"Hex"]==0)
		[self octtoHex:inputText];
	
	//Octal to Decimal
	else if ([rowOfComponent1 compare:@"Octal"]==0 && [rowOfComponent2 compare:@"Decimal"]==0)
		[self octtoDec:inputText];
	
	//Octal to Binary
	else if ([rowOfComponent1 compare:@"Octal"]==0 && [rowOfComponent2 compare:@"Binary"]==0)
		[self octtoBin:inputText fromFunction:NO];
	
	else
	{
		NSLog(@"There is an error");
		NSLog(@"Component 1: \%@",rowOfComponent1);
		NSLog(@"Component 2: \%@",rowOfComponent2);
        [input resignFirstResponder];
        NSString *newstring1 = [[NSString alloc] initWithFormat:@"%@ to %@",rowOfComponent1, rowOfComponent2];
        UIAlertView *notValid = [[UIAlertView alloc] initWithTitle:@"No Conversion" message:newstring1 
                                                           delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
		[notValid show];
        //output.text = @"Invalid Conversion";
		//[inputText dealloc]; WRONG (used to be right);
	}
}

 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
 [super viewDidLoad];
	 rowOfComponent1 = @"Binary";
	 rowOfComponent2 = @"Decimal";
	 NSLog(rowOfComponent1);
	 NSLog(rowOfComponent2);
 }

/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */


- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
    
	[self dismissModalViewControllerAnimated:YES];
    base1.text = rowOfComponent1;
    base2.text = rowOfComponent2;
}


- (IBAction)showInfo {    
	
	FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
	controller.delegate = self;
	
	controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:controller animated:YES];
	
	[controller release];
}

/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	NSLog(@"Memory Warning Kyle");
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
	[globalString release];
}

//Input Verification Methods
- (BOOL)checkBinary:(NSString *)inputText
{
	for (int i = 0; i < inputText.length-1; i++) {
		if ([inputText characterAtIndex:i] == '0' || [inputText characterAtIndex:i] == '1')
			return YES;
		else 
			return NO;

	}
}

- (BOOL)checkDecimal:(NSString *)inputText
{
	for (int i = 0; i < inputText.length-1; i++) {
		
	}
}

- (BOOL)checkHex:(NSString *)inputText
{
	for (int i = 0; i < inputText.length-1; i++) {
		
	}
}

- (BOOL)checkOctal:(NSString *)inputText
{
	for (int i = 0; i < inputText.length-1; i++) {
		
	}
}

//Binary to ** converions
- (void)bintoDec:(NSString *)inputText fromFunction:(BOOL)fromFunc
{
    Conversion *converter = new Conversion();
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->bintodec(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
	/*
    UIAlertView *notBinary = [[UIAlertView alloc] initWithTitle:@"Input Error" message:@"Not a valid Binary number!" 
				delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; //Set Alert to show Invalid Entry
	
	long long decimal = 0;
	int power = 0;
	
	NSLog(@"Binary to Decimal");

	for (int i = inputText.length-1; i >= 0; i--) 
	{
		if ([inputText characterAtIndex:i] == '0') 
		{
			NSLog(@"This character is 0");
		}
		else if ([inputText characterAtIndex:i] == '1')
		{
			NSLog(@"This character is 1");
			decimal = decimal+pow(2, power);
		}
		else 
		{
			//Input Verification (Same for all Binary functions)
			[notBinary show]; //Show alert if there is a character other than 0 or 1
			NSLog(@"Not Valid");
			output.text = @"??"; //Change label to "??"
			[input resignFirstResponder]; //Hide keyboard
			[notBinary release]; //Release the UIAlertView Object to avoid memory leakage
			return; //break the for loop so that the output.text in the next statement is not shown
		}
		power++;
        if (!fromFunc)
            output.text = [NSString stringWithFormat:@"%llu", decimal];
	}
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */

}

- (void)bintoHex:(NSString *)inputText fromFunction:(BOOL)fromFunc
{
    Conversion *converter = new Conversion();
    
	converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->bintohex(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
    UIAlertView *notBinary = [[UIAlertView alloc] initWithTitle:@"Input Error" message:@"Not a valid Binary number!" 
						delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; //Set Alert to show Invalid Entry
	
	NSLog(@"Binary to Hex");
	
	long long decimal = 0;
	int power = 0;
	
	for (int i = inputText.length-1; i >= 0; i--) 
	{
		if ([inputText characterAtIndex:i] == '0') 
		{
			NSLog(@"This character is 0");
		}
		else if ([inputText characterAtIndex:i] == '1')
		{
			NSLog(@"This character is 1");
			decimal = decimal+pow(2, power);
		}
		else 
		{
			//Input Verification (Same for all Binary functions)
			[notBinary show];
			NSLog(@"Not Valid");
			output.text = @"??";
			[input resignFirstResponder];
			[notBinary release];
			return;
		}
		power++;
		
	}
	ostringstream s(ostringstream::out);
	s << hex;
	s << decimal;
	
	string dude1 = s.str();
	
	for (int i = 0; i < dude1.length(); i++)
		dude1[i] = toupper(dude1[i]);
	
	NSString *newString = [[NSString alloc] initWithCString:dude1.c_str()];
	NSLog(newString);
	
    if (!fromFunc)
        output.text = newString;
	
	[input resignFirstResponder];
     */
}

- (void)bintoOct:(NSString *)inputText fromFunction:(BOOL)fromFunc
{
    Conversion *converter = new Conversion();
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->bintooct(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
	
    /*
    UIAlertView *notBinary = [[UIAlertView alloc] initWithTitle:@"Input Error" message:@"Not a valid Binary number!" 
				delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; //Set Alert to show Invalid Entry

	NSLog(@"Binary to Octal");
	
	long long decimal = 0;
	int power = 0;
	
	for (int i = inputText.length-1; i >= 0; i--) 
	{
		if ([inputText characterAtIndex:i] == '0') 
		{
			NSLog(@"This character is 0");
		}
		else if ([inputText characterAtIndex:i] == '1')
		{
			NSLog(@"This character is 1");
			decimal = decimal+pow(2, power);
		}
		else 
		{
			//Input Verification (Same for all Binary functions)
			[notBinary show];
			NSLog(@"Not Valid");
			output.text = @"??";
			[input resignFirstResponder];
			[notBinary release];
			return;
		}
		power++;
		
	}
	
	ostringstream s1(ostringstream::out);
	s1 << oct;
	s1 << decimal;
	
	string dude2 = s1.str();
	
	for (int i = 0; i < dude2.length(); i++)
		dude2[i] = toupper(dude2[i]);
	
	NSString *newString = [[NSString alloc] initWithCString:dude2.c_str() encoding:NSUTF8StringEncoding];
	NSLog(newString);
	
    if (!fromFunc)
        output.text = newString;
	
	[input resignFirstResponder];
     */
}

//Decimal to ** conversions

- (void)dectoBin:(NSString *)inputText
{	
	NSLog(@"Decimal to Binary");
	
    Conversion *converter = new Conversion();
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->dectobin(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
	
    /*
    string solution;
	stack <int> answer;
	int number;
	int digit;
	
	NSLog(@"The integer value of the string = %i", [inputText integerValue]); //this outputs the correct integer value
	
	number = [inputText integerValue]; //set number equal to integer value of inputText
	
	while (number!=0) {
		digit = number%2; //sets digit equal to 0 or 1
		answer.push(digit); //puts the 0 or 1 onto stack so that it can be reversed at the end 
		number = number/2;
	}
	
	while (!(answer.empty())) {
			solution.push_back(answer.top()+48); //put number from top of stack onto back of solution string
												 //add 48 to make it a character that is displayable
			answer.pop(); //pop the top number off of the stack
	}
	
		
	NSString *final = [[NSString alloc] initWithCString:solution.c_str()]; //set NSString to solution string
	output.text = final; //set the output equal to the NSString: final
	[input resignFirstResponder];
	[final release];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

- (void)dectoHex:(NSString *)inputText
{
	NSLog(@"Decimal to Hex");
	
    Conversion *converter = new Conversion();
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->dectohex(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
	//string hexadecimalNumber;
	const char* hexadecimalNumber;
    hexadecimalNumber = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
    
    cout<<"decimal number:"<<hexadecimalNumber<<endl;
	
    stringstream s2;
	s2 << hexadecimalNumber;
    int length = s2.str().length();
    
    int temp;
    s2 >> temp;
    char converted[length];
    sprintf(converted, "%X", temp);
    cout << "converted:" << converted << endl;
	
	//string dude3 = s2.str();
	
    //cout << "hex number:" << dude3<<endl;
    
    
    output.text = [NSString stringWithCString:converted encoding:NSUTF8StringEncoding];
	//output.text = [NSString stringWithCString:dude3.c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

- (void)dectoOct:(NSString *)inputText
{
    NSLog(@"Decimal to Octal");
    
    Conversion *converter = new Conversion();
	
	converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->dectooct(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
    const char* DecimalNumber;
    DecimalNumber = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
	
    stringstream s2;
	s2 << DecimalNumber;
    int length = s2.str().length();
    
    int temp;
    s2 >> temp;
    char converted[length];
    sprintf(converted, "%o", temp);
    cout << "converted:" << converted << endl;
	
    output.text = [NSString stringWithCString:converted encoding:NSUTF8StringEncoding];
		
    [input resignFirstResponder];
    //[inputText dealloc]; WRONG (used to be right);
     */
}

//Hexadeimal to ** conversions

- (void)hextoBin:(NSString *)inputText fromFunction:(BOOL)fromFunc
{
	NSLog(@"Hex to Binary");
	
    Conversion *converter = new Conversion();
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->hextobin(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
    string zero = "0000";
    string one = "0001";
    string two = "0010";
    string three = "0011";
    string four = "0100";
    string five = "0101";
    string six = "0110";
    string seven = "0111";
    string eight = "1000";
    string nine = "1001";
    string a = "1010";
    string b = "1011";
    string c = "1100";
    string d = "1101";
    string e = "1110";
    string f = "1111";
    
    stringstream convertedStream;
    
    for (int n=0; n < inputText.length; n++)
    {
        switch ([inputText characterAtIndex:n])
        {
            case '0':
                convertedStream << zero;
                break;
            case '1':
                convertedStream << one;
                break;
            case '2':
                convertedStream << two;
                break;
            case '3':
                convertedStream << three;
                break;
            case '4':
                convertedStream << four;
                break;
            case '5':
                convertedStream << five;
                break;
            case '6':
                convertedStream << six;
                break;
            case '7':
                convertedStream << seven;
                break;
            case '8':
                convertedStream << eight;
                break;
            case '9':
                convertedStream << nine;
                break;
            case 'A':
                convertedStream << a;
                break;
            case 'a':
                convertedStream << a;
                break;
            case 'B':
                convertedStream << b;
                break;
            case 'b':
                convertedStream << b;
                break;
            case 'C':
                convertedStream << c;
                break;
            case 'c':
                convertedStream << c;
                break;
            case 'D':
                convertedStream << d;
                break;
            case 'd':
                convertedStream << d;
                break;
            case 'E':
                convertedStream << e;
                break;
            case 'e':
                convertedStream << e;
                break;
            case 'F':
                convertedStream << f;
                break;
            case 'f':
                convertedStream << f;
                break;
            default:
                UIAlertView *notHex = [[UIAlertView alloc] initWithTitle:@"Input Error" message:@"Not a valid Hexadecimal number!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [notHex show];
                break;
        }
    }
    
    if (!fromFunc)
        output.text = [NSString stringWithCString:convertedStream.str().c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

- (void)hextoDec:(NSString *)inputText
{
	NSLog(@"Hex to Decimal");
	
    Conversion *converter = new Conversion(); //hextobin
    Conversion *converter2 = new Conversion(); //bintodec
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    //converter->hextodec(false);
    converter->hextobin(false);
    string newstring1 = converter->getConvertedString();
    converter2->setInputString(newstring1);
    converter2->bintodec(false);
    NSString *newString = [[NSString alloc] initWithCString:converter2->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
	string hexadecimalNumber2;
	hexadecimalNumber2 = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
	
	ostringstream s5(ostringstream::out);
	s5 << dec;
	s5 << hexadecimalNumber2;
	
	string dude6 = s5.str();
	
	output.text = [NSString stringWithCString:dude6.c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

- (void)hextoOct:(NSString *)inputText
{
	NSLog(@"Hex to Octal");
	
    Conversion *converter = new Conversion(); //hextobin
    Conversion *converter2 = new Conversion(); //bintooct
    
    converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->hextobin(false);
    string newstring1 = converter->getConvertedString();
    converter2->setInputString(newstring1);
    converter2->bintooct(false);
    NSString *newString = [[NSString alloc] initWithCString:converter2->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
	/*
    string octalNumber1;
	octalNumber1 = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
	
	ostringstream s6(ostringstream::out);
	s6 << dec;
	s6 << octalNumber1;
	
	string dude7 = s6.str();
	
	output.text = [NSString stringWithCString:dude7.c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

//Octal to ** conversions

- (void)octtoBin:(NSString *)inputText fromFunction:(BOOL)fromFunc
{
	NSLog(@"Octal to Binary");
	
    Conversion *converter = new Conversion();
    
	converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->octtobin(false);
    NSString *newString = [[NSString alloc] initWithCString:converter->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
    string octalNumber4;
	octalNumber4 = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
	
	ostringstream s9(ostringstream::out);
	s9 << dec;
	s9 << octalNumber4;
	
	string dude10 = s9.str();
	
	long long decimal2;
	string decimalstring2;
	string finalstring2;
	
	for (int p = 0; p<inputText.length-1; p++)
	{
		decimalstring2.at(p) = [inputText characterAtIndex:p];
	}
	
	for (int q = 0; q<sizeof(decimalstring2); q++)
		decimal2 = decimal2*10 + decimalstring2.at(q) - 48;
	
	for (int r = 0; r<sizeof(decimal2); r++)
	{
		finalstring2.push_back(decimal2%2);
		decimal2 = decimal2 / 2;
	}
	
	if (!fromFunc)
        output.text = [NSString stringWithCString:finalstring2.c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

- (void)octtoDec:(NSString *)inputText
{
	NSLog(@"Octal to Decimal");
	
    Conversion *converter = new Conversion(); //octtobin
    Conversion *converter2 = new Conversion(); //bintodec
    
	converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->octtobin(false);
    string newstring1 = converter->getConvertedString();
    converter2->setInputString(newstring1);
    converter2->bintodec(false);
    NSString *newString = [[NSString alloc] initWithCString:converter2->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
    string octalNumber3;
	octalNumber3 = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
	
	ostringstream s8(ostringstream::out);
	s8 << dec;
	s8 << octalNumber3;
	
	string dude9 = s8.str();
	
	output.text = [NSString stringWithCString:dude9.c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
	*/
}

- (void)octtoHex:(NSString *)inputText
{
	NSLog(@"Octal to Hex");
	
    Conversion *converter = new Conversion(); //octtobin
    Conversion *converter2 = new Conversion(); //bintohex
    
	converter->setInputString([inputText cStringUsingEncoding:NSUTF8StringEncoding]);
    converter->octtobin(false);
    string newstring1 = converter->getConvertedString();
    converter2->setInputString(newstring1);
    converter2->bintohex(false);
    NSString *newString = [[NSString alloc] initWithCString:converter2->getConvertedString().c_str() encoding:NSUTF8StringEncoding];
    output.text = newString;
    [input resignFirstResponder];
    
    /*
    string octalNumber2;
	octalNumber2 = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
	
	ostringstream s7(ostringstream::out);
	s7 << hex;
	s7 << octalNumber2;
	
	string dude8 = s7.str();
	
	output.text = [NSString stringWithCString:dude8.c_str() encoding:NSUTF8StringEncoding];
	
	[input resignFirstResponder];
	//[inputText dealloc]; WRONG (used to be right);
     */
}

@end